package br.com.caelum.controller;

import java.util.List;

import br.com.caelum.dao.TurmaDAO;
import br.com.caelum.model.Aluno;
import br.com.caelum.model.Turma;
import br.com.caelum.vraptor.Resource;
import br.com.caelum.vraptor.Result;

@Resource
public class TurmasController {
	private final TurmaDAO dao;
	private final Result result;
	
	public TurmasController(TurmaDAO dao, Result result) {
		this.dao = dao;
		this.result = result;
	}
	
	public void adiciona(Turma turma) {
		dao.salva(turma);
		result.redirectTo(this).lista();
	}
	
	public void altera(Turma turma) {
		dao.atualiza(turma);
		result.redirectTo(this).lista();
	}
	
	public Turma edita(Long id) {
		return dao.carrega(id);
	}
	
	public List<Turma> lista() {
		return dao.listaTudo();
	}
	
	public void formulario() {
	}
}
